package com.zhen.module.contorller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ModelAndViewContorller {
    @RequestMapping("/doModelAndView")
    public ModelAndView doModelAndView(ModelAndView mv){
        mv.addObject("name","jason");
        mv.setViewName("index");
        return mv;
    }

    @RequestMapping("/doModelAndView02")
    public ModelAndView doModelAndView02(ModelAndView mv){
       List<String> list = new ArrayList<>();
       list.add("北京");
       list.add("深圳");
       list.add("上海");
       mv.addObject("citys",list);
       mv.setViewName("index");
       return mv;
    }
}
